package org.oschina.handler.validator.filter;

import org.apache.commons.lang.StringUtils;
import org.oschina.api.manage.illegalchar.service.IllegalCharService;
import org.oschina.handler.validator.IFilter;
import org.oschina.handler.validator.ValidateBean;
import org.oschina.util.JsoupUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *	HTML过滤
 */
@Component
public class HtmlCleanFileter implements IFilter {

	@Autowired
	private IllegalCharService illegalCharService;
	
	@Override
	public void execute(ValidateBean validateBean)
	{
		if(StringUtils.isBlank(validateBean.getValue()))
			return;
		
		validateBean.setValue(JsoupUtil.clean(StringUtils.trim(validateBean.getValue())));
		validateBean.setValue(illegalCharService._clean(validateBean.getValue()));
	}

}